package ${(packageStr)!''}.controller;

import java.util.List;
import com.lnsoft.common.core.controller.BaseController;
import com.lnsoft.common.core.page.TableDataInfo;
import com.lnsoft.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ${(packageStr)!''}.domain.${(beanName)!''};
import ${(packageStr)!''}.query.${(beanName)!''}Query;
import ${(packageStr)!''}.service.${(beanName)!''}Service;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

@RestController
@RequestMapping("/${(beanParam)!''}")
@Api(tags = "${(moduleName)!''}")
public class ${(beanName)!''}Controller extends BaseController
{
    @Autowired
    private ${(beanName)!''}Service ${(beanParam)!''}Service;

    @ApiOperation("查询${(moduleName)!''}列表")
    @GetMapping("/list")
    public TableDataInfo list(${(beanName)!''}Query ${(beanParam)!''}Query)
    {
        startPage();
        List<${(beanName)!''}> list = ${(beanParam)!''}Service.select${(beanName)!''}List(${(beanParam)!''}Query);
        return getDataTable(list);
    }

    @ApiOperation("查询${(moduleName)!''}详情")
    @GetMapping(value = "/{${keyColumn.columnName}}")
    public AjaxResult getInfo(@PathVariable Long ${keyColumn.columnName})
    {
        return success(${(beanParam)!''}Service.select${(beanName)!''}ById(${keyColumn.columnName}));
    }

    @ApiOperation("新增${(moduleName)!''}")
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody ${(beanName)!''} ${(beanParam)!''})
    {
        return toAjax(${(beanParam)!''}Service.insert${(beanName)!''}(${(beanParam)!''}));
    }

    @ApiOperation("修改${(moduleName)!''}")
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody ${(beanName)!''} ${(beanParam)!''})
    {
        return toAjax(${(beanParam)!''}Service.update${(beanName)!''}(${(beanParam)!''}));
    }

    @ApiOperation("删除${(moduleName)!''}")
    @PostMapping("/{${keyColumn.columnName}s}")
    public AjaxResult remove(@PathVariable Long[] ${keyColumn.columnName}s)
    {
        return toAjax(${(beanParam)!''}Service.delete${(beanName)!''}ByIds(${keyColumn.columnName}s));
    }
}
